package com.dd;

import java.util.HashMap;
import java.util.Map;

import com.chantel.tool.db.DBUtil;

public class UserToXiangMu {
	private int id;
	private int yuanGongID;
	private int xiangMuID;
	
	public UserToXiangMu(int ygID,int xMID)
	{
		yuanGongID = ygID;
		xiangMuID = xMID;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getXiangMuID() {
		return xiangMuID;
	}

	public void setXiangMuID(int xiangMuID) {
		this.xiangMuID = xiangMuID;
	}

	public int getYuanGongID() {
		return yuanGongID;
	}

	public void setYuanGongID(int yuanGongID) {
		this.yuanGongID = yuanGongID;
	}
	
	public boolean InSertToDB()
	{
		DBUtil du = DBUtil.getInstance();
		Map m = new HashMap();
		m.put("YuanGongId", new Integer(this.yuanGongID));
		m.put("XiangMuId", new Integer(this.xiangMuID));
	
		
		boolean bool_res = du.insertRecord("YuanGongXiangMuTable", m);
		if (bool_res)
		{
			System.out.println("insert finish!");			
			
			return true;
		}
		else
		{
			System.out.println("insert error! s");
			return false;
		}		
	}
	public static boolean InSertToDBForShenHe(int yonggongId,int xiangmuID)
	{
		DBUtil du = DBUtil.getInstance();
		Map m = new HashMap();
		m.put("YuanGongId", new Integer(yonggongId));
		m.put("XiangMuId", new Integer(xiangmuID));
	
		
		boolean bool_res = du.insertRecord("YuanGongXiangMuTable", m);
		if (bool_res)
		{
			System.out.println("insert finish!");			
			
			return true;
		}
		else
		{
			System.out.println("insert error! s");
			return false;
		}		
	}
	
	
	public static boolean DeleteUserToXiangMu_GuanXi(int userID)
	{

		DBUtil du = DBUtil.getInstance();

		String sql = "delete from YuanGongXiangMuTable where YuanGongId = "
				+ ((Integer)(new Integer(userID))).toString();

		boolean bool_res = du.deleteRecords(sql);

		if (bool_res)
		{
			System.out.println("delete user to XiangMu finish!");			
			
			return true;
		}
		else
		{
			System.out.println("delete user to XiangMu error! s");
			return false;
		}	
	}
	
	public static void main(String[] args){
		UserToXiangMu user = new UserToXiangMu(2,8);
		user.InSertToDB();
		
		System.out.println(user.getXiangMuID());
		
	}
	
}